<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="string" uri="http://jakarta.apache.org/taglibs/string-1.1" %>
<%@ taglib uri="/WEB-INF/tlds/pagination.tld" prefix="pagination" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <title>Dayve web</title>
    <link href="/common/css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/common/js/common.js"></script>
    <script type='text/javascript' src="/common/dwr/engine.js"></script>
    <script type='text/javascript' src="/common/dwr/util.js"></script>
    <script type="text/javascript">
        // Locale 설정을 바꾼다.
        function jsChangeLocaleKR() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "index";
            TheForm.action = "${pageContext.request.contextPath}/changeLocale.do?language=kr";
            TheForm.submit();
        }

        function jsChangeLocaleEN() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "index";
            TheForm.action = "${pageContext.request.contextPath}/changeLocale.do?language=en";
            TheForm.submit();
        }

        function jsChangeLocaleZH() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "index";
            TheForm.action = "./changeLocale.do?language=zh";
            TheForm.action = "${pageContext.request.contextPath}/changeLocale.do?language=zh";
            TheForm.submit();
        }

        // Community Board List 페이지로 이동한다.
        function jsCommunityBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "communityBoardList";	// page name
            TheForm.action = "./communityBoardList.do";
            TheForm.submit();
        }

        // Photo Board List 페이지로 이동한다.
        function jsPhotoBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "photoBoardList";	// page name
            TheForm.action = "./photoBoardList.do";
            TheForm.submit();
        }

        // Notice Board List 페이지로 이동한다.
        function jsNoticeBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "noticeBoardList";	// page name
            TheForm.action = "./noticeBoardList.do";
            TheForm.submit();
        }

        // 회원탈퇴
        function jsDeleteMember() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "index";	// page name
            TheForm.action = "./deleteMemberById.do";
            TheForm.submit();
        }

        // Contact Us 페이지로 이동한다.
        function jsContactUs() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "contactus";	// page name
            TheForm.action = "./contactus.do";
            TheForm.submit();
        }

        // FAQ 페이지로 이동한다.
        function jsFAQ() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "faq";	// page name
            TheForm.action = "./faq.do";
            TheForm.submit();
        }

        // frm 의 첨부파일 버튼 초기화
        function jsFileReset() {
            document.frm.fileUp.select();
            document.selection.clear();
        }

        // 회원정보 수정
        function jsUpdateMember() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "updateMember";	// page name
            TheForm.action = "./updateMember.do";
            TheForm.submit();
        }

        // 회원정보 수정
        function jsLogout() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "index";	// page name
            TheForm.action = "./logout.do";
            TheForm.submit();
        }

        // 메일 보내기
        function jsSendContact() {
            var TheForm = document.frm;
            if(trim(TheForm.content.value) == ""){
//                alert('내용을 입력하세요.');
                alert('<spring:message code="myPage.jsSendContact.inputCheck" />');
                TheForm.content.value = "";
                TheForm.content.focus();
                return false;
            }else{
                var now = new Date();                                                  // 현재시간
//                var nowTime = now.getFullYear() + "년" + (now.getMonth()+1) + "월" + now.getDate() + "일" + now.getHours() + "시" + now.getMinutes() + "분" + now.getSeconds() + "초";
                var nowTime = now.getFullYear() + "<spring:message code="myPage.nowTime.yaer" />" + (now.getMonth()+1) + "<spring:message code="myPage.nowTime.month" />" + now.getDate() + "<spring:message code="myPage.nowTime.day" />" + now.getHours() + "<spring:message code="myPage.nowTime.hour" />" + now.getMinutes() + "<spring:message code="myPage.nowTime.minute" />" + now.getSeconds() + "<spring:message code="myPage.nowTime.second" />";
                TheForm.date.value = nowTime;

                for(i = 0; i<TheForm.flag.length; i++){
                    if(TheForm.flag[i].checked == true){
                        TheForm.category.value = TheForm.flag[i].value;
                    }
                }
//                alert('소중한 문의 감사드립니다.');
                alert('<spring:message code="myPage.thanks" />');
                TheForm.nextTarget.value = "intro";	// page name
                TheForm.action = "./sendContact.do";
                TheForm.submit();
            }
        }

        function jsLogin(){
//            alert('로그인이 필요합니다.');
            alert('<spring:message code="myPage.needLogin" />');
//            if(confirm('로그인 페이지로 이동하시겠습니까?')){
            if(confirm('<spring:message code="myPage.loginGo" />')){
                location.href = "index.do";
            }else{
                return false;
            }
        }

        function getLastDay(y, m){
            var lastdate = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); //각 달의 마지막 날짜

            year = y;
            if((0==year%4&&0!=year%100)||0==year%400){ //year를 가지고 윤년인지 검사.
                lastdate[1] = 29; /*윤년인 경우 2월의 마지막 날짜를 29로 입력*/
            }
            month = m;
            day = lastdate[month-1];
            return day;
        }


        function myPageContent(categoryId) {
            var TheForm = document.frm;
            var now = new Date();
            var month = now.getMonth()+1;
            if(month < 10){
                month = "0" + month;
            }
            TheForm.date.value = now.getFullYear() + "-" + month;
            TheForm.lastDay.value = getLastDay(now.getFullYear(), month);

            TheForm.id_myhistory_categories.value = categoryId;
            TheForm.action = "./myPageContent.do";
            TheForm.submit();
        }

    </script>
</head>

<body>
<div id="wrapper">
    <!------------------------------ top 시작-------------------------------------->
    <%@include file="header.jsp" %>
    <!------------------------------ top 끝-------------------------------------->
    <div class="mypage_content">
        <img src="/images/intro/sub_title07.gif" class="mypage_title" />
        <div>
            <%--<div class="mypage_category">카테고리 목록</div>--%>
            <div class="mypage_category"><spring:message code="myPage.mypage_category" /></div>
            <%--<div class="mypage_info">카테고리 <strong>${totalCount}개</strong> ㅣ 아이템 <strong>${totalItemCount}개</strong> ㅣ 즐겨찾기 <strong>${totalFavorite}개</strong> ㅣ 마일리지 <strong>${mileage}점</strong></div>--%>
            <div class="mypage_info"><spring:message code="myPage.mypage_info1" /> <strong>${totalCount}<spring:message code="myPage.mypage_info2" /></strong> ㅣ <spring:message code="myPage.mypage_info3" /> <strong>${totalItemCount}<spring:message code="myPage.mypage_info4" /></strong> ㅣ <spring:message code="myPage.mypage_info5" /> <strong>${totalFavorite}<spring:message code="myPage.mypage_info6" /></strong> ㅣ <spring:message code="myPage.mypage_info7" /> <strong>${mileage}<spring:message code="myPage.mypage_info8" /></strong></div>
        </div>
        <div class="mypage_bg">
            <form name="frm" method="POST">
                <input type="hidden" name="id_myhistory_categories" value="">
                <input type="hidden" name="date" value="">
                <input type="hidden" name="lastDay" value="">

                <div class="mypage_right">
                    <img src="/images/intro/mypage_intro.gif" class="mypage_img" />
                </div>
                <ul>
                    <c:forEach items="${categoryList}" var="categoryList" varStatus="serviceStatus" begin="0" end="${totalCount}"
                               step="1">
                        <li><a href="javascript:myPageContent(${categoryList.id_myhistory_categories})">${categoryList.name}</a></li>
                    </c:forEach>
                </ul>
                <div class="clear"></div>
            </form>
        </div>
    </div>
    <!------------------------------ 하위메뉴 시작-------------------------------------->
    <%@include file="footer.jsp" %>
    <!------------------------------ 하위메뉴 끝-------------------------------------->

</div>
</body>
</html>